import time
import requests

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36"
}

t_stamp = int(time.time() * 1000)
url = 'http://d1.weather.com.cn/calendar_new/2021/101210101_202105.html?_=' + str(t_stamp)
response = requests.get(url, headers=headers)  # 生成一个response对象
print("状态码:" + str(response.status_code))  # 打印状态码
print(response.text)

dic = dict()
str = response.text[response.text.find('['):]
obj = eval(str)

# print('date',obj[0]['date'],'hmax',obj[0]['hmax'], 'hmin',obj[0]['hmin'])
for ele in obj:
    dic[ele['date']] = {'max_temp': ele['hmax'], 'min_temp': ele['hmin'], 'rain_poss': ele['hgl']}

print(dic)
